API Documentation
Public Member Functions | List of all members
nkGraphics::Resource Class Referenceabstract

Base class for a resource in the component. More...

Inheritance diagram for nkGraphics::Resource:
nkGraphics::BlendState nkGraphics::Compositor nkGraphics::DepthStencilState nkGraphics::Mesh nkGraphics::Program nkGraphics::RasterState nkGraphics::ResourceNodeWrapper nkGraphics::Sampler nkGraphics::Shader nkGraphics::ShaderResource

Public Member Functions

 Resource ()
 
 Resource (const char *path)
 
virtual ~Resource ()
 
virtual bool load ()=0
 
virtual void unload ()=0
 
bool isReadyForRendering () const
 
bool isUnloaded () const
 
RESOURCE_LOAD_STATE getLoadState () const
 
std::string_view getResourcePath () const
 
RESOURCE_TYPE getResourceTypeName () const
 
std::string_view getResourceName () const
 
bool getHidden () const
 
virtual void setResourcePath (const std::string_view &path)
 
void setResourceName (const std::string_view &name)
 
void setHidden (bool value)
 

Detailed Description

Base class for a resource in the component.

Constructor & Destructor Documentation

◆ Resource() [1/2]

nkGraphics::Resource::Resource ( )

Default constructor.

◆ Resource() [2/2]

nkGraphics::Resource::Resource ( const char *  path)

Filling constructor.

Parameters
pathThe path of the resource.

◆ ~Resource()

virtual nkGraphics::Resource::~Resource ( )
virtual

Destructor.

Member Function Documentation

◆ load()

virtual bool nkGraphics::Resource::load ( )
pure virtual

Loading function. A resource goes into different states through its lifetime.

  • Created. It is awaiting configuration by external code. At this point, the resource can already be used everywhere, but it will have default values, often resulting in a no-op.
  • Loading. The configuration has been made and the load function has been called. For some resources, this status is bypassed.
  • Loaded. The resource has been loaded and all memory has been populated. At this point, the resource should operate as described.

It is possible to loop through these states during the resource lifetime, if needed.

Returns
Whether the loading went well (true) or not (false).

Implemented in nkGraphics::Program, nkGraphics::Shader, and nkGraphics::Compositor.

◆ unload()

virtual void nkGraphics::Resource::unload ( )
pure virtual

Unloads the resource, and places it back into its created state. Frees all internal memory used to initialize it.

Implemented in nkGraphics::Program, nkGraphics::Shader, and nkGraphics::Compositor.

◆ isReadyForRendering()

bool nkGraphics::Resource::isReadyForRendering ( ) const
Returns
Whether the resource is ready for rendering (true) or not (false). A resource is ready if it is loaded and all memory is populated.

◆ isUnloaded()

bool nkGraphics::Resource::isUnloaded ( ) const
Returns
Whether the resource is unloaded (true) or not (false).

◆ getLoadState()

RESOURCE_LOAD_STATE nkGraphics::Resource::getLoadState ( ) const

The current load state of the resource.

◆ getResourcePath()

std::string_view nkGraphics::Resource::getResourcePath ( ) const
Returns
The resource path, relative to the working directory. See nkResources::ResourceManager for path naming conventions.

◆ getResourceTypeName()

RESOURCE_TYPE nkGraphics::Resource::getResourceTypeName ( ) const
Returns
The resource type name.

◆ getResourceName()

std::string_view nkGraphics::Resource::getResourceName ( ) const
Returns
The resource name.

◆ getHidden()

bool nkGraphics::Resource::getHidden ( ) const
Returns
Whether the resource is hidden (true) or not (false). A hidden resource is not processed for saving when exporting a resource set.

◆ setResourcePath()

virtual void nkGraphics::Resource::setResourcePath ( const std::string_view &  path)
virtual

Sets the resource's path, relative to the working directory. See nkResources::ResourceManager for path naming conventions.

Parameters
pathThe path to use.

Reimplemented in nkGraphics::Texture.

◆ setResourceName()

void nkGraphics::Resource::setResourceName ( const std::string_view &  name)

Sets the resource name.

Parameters
nameThe resource name to use.

◆ setHidden()

void nkGraphics::Resource::setHidden ( bool  value)

Sets whether the resource is hidden or not. Hidden resource do not contribute to resource set save requests.

Parameters
valueWhether the resource should be hidden (true) or not (false).

The documentation for this class was generated from the following file: